/**
 * Created by HiWin10 on 2016/8/2.
 */

(function() {
    'use strict';

    angular
        .module('app.student.list', ['']).controller('StudentDetailCtrl',StudentDetailCtrl);
    StudentDetailCtrl.$inject=['$scope','studentdetail',$uibModalInstance,'getdataservice'];
    function StudentDetailCtrl($scope,studentdetail,$uibModalInstance,getdataservice) {
        studentdetail.Student_isbd==1 ? $scope.baodao=true:$scope.baodao=false;
        $scope.studentdetail=studentdetail;
        $scope.getexcel=baseurl+"/Excel/GetStudentsExcel/"+studentdetail.Spe_id;
        $scope.close=function () {
            $uibModalInstance.dismiss('close');
        }
        $scope.CancelBaodao=function (id) {
            swal({
                title:'确认报道取消吗',
                html:'确认通知书号为:<span class="text-bold text-danger">'+studentdetail.Student_tzsh+'</span>、姓名为:<span class="text-bold text-danger">'+studentdetail.Student_name+'</span>取消报到吗？',
                type:'error',
                showCancelButton: true,
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                allowOutsideClick:false,
                allowEscapeKey:false
            }).then(function (isConfirm) {
                if (isConfirm==true)
                {
                    getdataservice.all("/student/cancelbaodao/"+studentdetail.Student_id+"/?v="+new Date().getTime()).then(
                        function (data) {
                            if (data.ResultCode!=200)
                            {
                                swal({
                                    title:'出错！',
                                    text:data.Memo,
                                    type:'error',
                                    allowOutsideClick:false,
                                    allowEscapeKey:false
                                })
                            }
                            else
                            {

                                swal({
                                    title:'恭喜！',
                                    text:'该生取消报道成功',
                                    type:'success',
                                    allowOutsideClick:false,
                                    allowEscapeKey:false
                                });
                                getdataservice.all("/Student/Details/"+studentdetail.Student_id+"/?id="+new Date().getTime()).then(
                                    function (data) {
                                        if (data.ResultCode!=200)
                                        {
                                            swal({
                                                title:'出错！',
                                                text:data.Memo,
                                                type:'error',
                                                allowOutsideClick:false,
                                                allowEscapeKey:false
                                            })
                                        }else {
                                            data.Data.Student_isbd==1 ? $scope.baodao=true:$scope.baodao=false;
                                            $scope.studentdetail=data.Data;

                                        }
                                    }
                                )



                            }

                        }
                    )
                }
            })

        }
        $scope.ConfirmBaodao=function (id) {
            swal({
                title:'确认吗',
                html:'确认通知书号为:<span class="text-bold text-danger">'+studentdetail.Student_tzsh+'</span>、姓名为:<span class="text-bold text-danger">'+studentdetail.Student_name+'</span>报到吗？',
                type:'question',
                showCancelButton: true,
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                allowOutsideClick:false,
                allowEscapeKey:false
                }).then(function (isConfirm) {
                if (isConfirm==true)
                {
                    getdataservice.all("/student/confirmbaodao/"+studentdetail.Student_id+"/?v="+new Date().getTime()).then(
                        function (data) {
                            if (data.ResultCode!=200)
                            {
                                swal({
                                    title:'出错！',
                                    text:data.Memo,
                                    type:'error',
                                    allowOutsideClick:false,
                                    allowEscapeKey:false
                                })
                            }
                            else
                            {

                                swal({
                                    title:'恭喜！',
                                    text:'该生报道成功',
                                    type:'success',
                                    allowOutsideClick:false,
                                    allowEscapeKey:false
                                });
                                getdataservice.all("/Student/Details/"+studentdetail.Student_id+"/?id="+new Date().getTime()).then(
                                    function (data) {
                                        if (data.ResultCode!=200)
                                        {
                                            swal({
                                                title:'出错！',
                                                text:data.Memo,
                                                type:'error',
                                                allowOutsideClick:false,
                                                allowEscapeKey:false
                                            })
                                        }else {
                                            data.Data.Student_isbd==1 ? $scope.baodao=true:$scope.baodao=false;
                                            $scope.studentdetail=data.Data;
                                        }
                                    }
                                )



                            }

                        }
                    )
                }
            })
            
        }
    }
})();
